<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: Aug 21, 2009
  Time: 9:57:55 PM
  To change this template use File | Settings | File Templates.
--%>
<%@ page import="com.elookinto.util.*, java.text.*, java.util.*" contentType="text/html;charset=UTF-8"
         language="java" %>
<%@ page import="java.net.URLDecoder" %>
<html>
<head><title>Simple jsp page</title></head>
<body>Place your content here</body>

<form>
    <input type="text" name="q"/>
    <input type="submit"/>
</form>
<%

    String source = "this is testing 通行的多项规定, () + 通行的";
    String q = request.getParameter("q");
    //byte[] b = q.getBytes("ISO-8859-1");
    //q = new String(b);
    // out.print(q);

    q = new String(q.getBytes("ISO-8859-1"), "UTF-8");

    //out.println(Locale.getDefault());
    if (q != null)
        source = q;
    BreakIterator boundary = BreakIterator.getWordInstance();

    out.println("jsp bundar " + boundary);


    boundary.setText(source);
    Set<String> set = new HashSet<String>();
    int start = boundary.first();
    for (int end = boundary.next();
         end != BreakIterator.DONE;
         start = end, end = boundary.next()) {
        //out.println(source.substring(start,end));
        String temp = source.substring(start, end);
        boolean isWord = false;
        for (int p = start; p < end; p++) {
            if (Character.isLetter(source.codePointAt(p)))
                isWord = true;
        }
        if (isWord)
            set.add(temp);
    }

    for (String s : set)
        out.println("=----"+ s + "<br/>");

     

    List<String> list = QueryTermExtractor.extract(source);


    for (String s : list)
        out.println(s + "<br/>");
%>
</html>